<template>
	<div class="theme">
		<van-nav-bar :title="$t('MoneyDetails.v1')" :left-text="$t('MyDividend.v6')" left-arrow @click-left="onClickLeft" />
		<div class="overlay headTop">
			<div class="overlay-content scrolling" style="padding-top: 10px;">
				<van-pull-refresh v-model="isLoading" @refresh="onRefresh" pulling-text=" " :loosing-text="$t('MyDividend.v7')" :loading-text="$t('MyDividend.v8')">
					<div style="background: white;color: black;text-align: center;padding: 10px 0px;margin-bottom: 10px;" v-for="(item,index) in list" :key="item.index">
						<van-row>
							<van-col span="6">{{$t('MoneyDetails.v3')}}</van-col>
							<van-col span="6">币种类型</van-col>
							<van-col span="6">{{$t('MoneyDetails.v4')}}</van-col>
							<van-col span="6">{{$t('MoneyDetails.v2')}}</van-col>
						</van-row>
						<van-row style="color: rgb(125, 126, 128);font-size: 13px;padding-top: 5px;">
							<van-col span="6">{{item.total}}</van-col>
							<van-col span="6">{{item.payType == 1 ? 'USDT' : 'Estate'}}</van-col>
							<van-col span="6">{{parseFloat(Number(item.ratio * 100)).toFixed(3).slice(0,-1)}} %</van-col>
							<van-col span="6">{{item.createTime | formatDate}}</van-col>
						</van-row>
					</div>
					<div style="color: #969799;font-size: 13px;line-height: 50px;text-align: center">{{$t('MyTeam.v5')}}</div>
				</van-pull-refresh>
			</div>
		</div>
	</div>
</template>

<script>
	import { crowdfunding } from './../utils/api';
	import { formatDate } from './../utils/date';
	let _this;
	export default {
		name: "MoneyDetails",
		data() {
			return {
				list: [],
				isLoading: false
			}
		},
		beforeCreate() {
			_this = this;
		},
		mounted() {
			this.getList();
		},
		methods: {
			getList() {
				crowdfunding.getParticipate({
					projectId: this.$route.query.projectId,
				}).then(res => {
					if(res.code == 200) {
						this.list = res.data;
					}
				})
			},
			onRefresh() { // 下拉刷新
				this.getList();
				setTimeout(() => {
					this.$toast({
						duration: 800,
						message: "刷新成功",
						message: _this.$t('MyDividend.v10')
					});
					this.isLoading = false;
				}, 500);
			},
			onClickLeft() {
				this.$router.push({
					path: '/MyProject'
				});
			}
		},
		filters: {
			formatDate(time) {
				let date = new Date(time);
				return formatDate(date, 'yyyy-MM-dd hh:mm');
			}
		}
	}
</script>

<style lang="less" scoped>
	.overlay {
		background: rgb(245, 245, 245);
	}
	
	.head {
		background: white;
		color: black;
	}
	
	.head .return:after {
		border-color: black;
	}
	
	.van-pull-refresh {
		overflow: visible!important;
	}
</style>